﻿using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Joins;

namespace System.Reactive.Linq
{
	public static partial class Observable
	{
		public static IObservable<TSource> Take<TSource>(this IObservable<TSource> source, int count)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(count >= 0, null, "count >= 0");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Take<TSource>(this IObservable<TSource> source, int count, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(count >= 0, null, "count >= 0");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> TakeLast<TSource>(this IObservable<TSource> source, int count)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(count >= 0, null, "count >= 0");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> TakeUntil<TSource, TOther>(this IObservable<TSource> source, IObservable<TOther> other)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> TakeWhile<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(predicate != null, null, "predicate != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> TakeWhile<TSource>(this IObservable<TSource> source, Func<TSource, int, bool> predicate)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(predicate != null, null, "predicate != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static Plan<TResult> Then<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(selector != null, null, "selector != null");
			Contract.Ensures(Contract.Result<Plan<TResult>>() != null, null, "Contract.Result<Plan<TResult>>() != null");
			return null;
		}

		public static IObservable<TSource> Throttle<TSource, TThrottle>(this IObservable<TSource> source, Func<TSource, IObservable<TThrottle>> throttleDurationSelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(throttleDurationSelector != null, null, "throttleDurationSelector != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Throttle<TSource>(this IObservable<TSource> source, TimeSpan dueTime)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Throttle<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TResult> Throw<TResult>(Exception exception)
		{
			Contract.Requires(exception != null, null, "exception != null");
			Contract.Ensures(Contract.Result<IObservable<TResult>>() != null, null, "Contract.Result<IObservable<TResult>>() != null");
			return null;
		}

		public static IObservable<TResult> Throw<TResult>(Exception exception, IScheduler scheduler)
		{
			Contract.Requires(exception != null, null, "exception != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TResult>>() != null, null, "Contract.Result<IObservable<TResult>>() != null");
			return null;
		}

		public static IObservable<TimeInterval<TSource>> TimeInterval<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TimeInterval<TSource>>>() != null, null, "Contract.Result<IObservable<TimeInterval<TSource>>>() != null");
			return null;
		}

		public static IObservable<TimeInterval<TSource>> TimeInterval<TSource>(this IObservable<TSource> source, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TimeInterval<TSource>>>() != null, null, "Contract.Result<IObservable<TimeInterval<TSource>>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(timeoutDurationSelector != null, null, "timeoutDurationSelector != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(timeoutDurationSelector != null, null, "timeoutDurationSelector != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(firstTimeout != null, null, "firstTimeout != null");
			Contract.Requires(timeoutDurationSelector != null, null, "timeoutDurationSelector != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(firstTimeout != null, null, "firstTimeout != null");
			Contract.Requires(timeoutDurationSelector != null, null, "timeoutDurationSelector != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> Timeout<TSource>(this IObservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(other != null, null, "other != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<long> Timer(DateTimeOffset dueTime)
		{
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(TimeSpan dueTime)
		{
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(DateTimeOffset dueTime, IScheduler scheduler)
		{
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(DateTimeOffset dueTime, TimeSpan period)
		{
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(TimeSpan dueTime, IScheduler scheduler)
		{
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(TimeSpan dueTime, TimeSpan period)
		{
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
		{
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<long> Timer(TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
		{
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<long>>() != null, null, "Contract.Result<IObservable<long>>() != null");
			return null;
		}

		public static IObservable<Timestamped<TSource>> Timestamp<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<Timestamped<TSource>>>() != null, null, "Contract.Result<IObservable<Timestamped<TSource>>>() != null");
			return null;
		}

		public static IObservable<Timestamped<TSource>> Timestamp<TSource>(this IObservable<TSource> source, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<Timestamped<TSource>>>() != null, null, "Contract.Result<IObservable<Timestamped<TSource>>>() != null");
			return null;
		}

		public static IObservable<TSource[]> ToArray<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TSource[]>>() != null, null, "Contract.Result<IObservable<TSource[]>>() != null");
			return null;
		}

		public static IObservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Ensures(Contract.Result<IObservable<IDictionary<TKey, TSource>>>() != null, null, "Contract.Result<IObservable<IDictionary<TKey, TSource>>>() != null");
			return null;
		}

		public static IObservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(elementSelector != null, null, "elementSelector != null");
			Contract.Ensures(Contract.Result<IObservable<IDictionary<TKey, TElement>>>() != null, null, "Contract.Result<IObservable<IDictionary<TKey, TElement>>>() != null");
			return null;
		}

		public static IObservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(comparer != null, null, "comparer != null");
			Contract.Ensures(Contract.Result<IObservable<IDictionary<TKey, TSource>>>() != null, null, "Contract.Result<IObservable<IDictionary<TKey, TSource>>>() != null");
			return null;
		}

		public static IObservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(elementSelector != null, null, "elementSelector != null");
			Contract.Requires(comparer != null, null, "comparer != null");
			Contract.Ensures(Contract.Result<IObservable<IDictionary<TKey, TElement>>>() != null, null, "Contract.Result<IObservable<IDictionary<TKey, TElement>>>() != null");
			return null;
		}

		public static IEnumerable<TSource> ToEnumerable<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IEnumerable<TSource>>() != null, null, "Contract.Result<IEnumerable<TSource>>() != null");
			return null;
		}

		public static IEventSource<TSource> ToEvent<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IEventSource<TSource>>() != null, null, "Contract.Result<IEventSource<TSource>>() != null");
			return null;
		}

		public static IEventSource<Unit> ToEvent(this IObservable<Unit> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IEventSource<Unit>>() != null, null, "Contract.Result<IEventSource<Unit>>() != null");
			return null;
		}

		public static IEventPatternSource<TEventArgs> ToEventPattern<TEventArgs>(this IObservable<EventPattern<TEventArgs>> source)
#if SILVERLIGHT
 where TEventArgs : EventArgs
#endif
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IEventPatternSource<TEventArgs>>() != null, null, "Contract.Result<IEventPatternSource<TEventArgs>>() != null");
			return null;
		}

		public static IObservable<IList<TSource>> ToList<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<IList<TSource>>>() != null, null, "Contract.Result<IObservable<IList<TSource>>>() != null");
			return null;
		}

		public static ListObservable<TSource> ToListObservable<TSource>(this IObservable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<ListObservable<TSource>>() != null, null, "Contract.Result<ListObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Ensures(Contract.Result<IObservable<ILookup<TKey, TSource>>>() != null, null, "Contract.Result<IObservable<ILookup<TKey, TSource>>>() != null");
			return null;
		}

		public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(elementSelector != null, null, "elementSelector != null");
			Contract.Ensures(Contract.Result<IObservable<ILookup<TKey, TElement>>>() != null, null, "Contract.Result<IObservable<ILookup<TKey, TElement>>>() != null");
			return null;
		}

		public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(comparer != null, null, "comparer != null");
			Contract.Ensures(Contract.Result<IObservable<ILookup<TKey, TSource>>>() != null, null, "Contract.Result<IObservable<ILookup<TKey, TSource>>>() != null");
			return null;
		}

		public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(keySelector != null, null, "keySelector != null");
			Contract.Requires(elementSelector != null, null, "elementSelector != null");
			Contract.Requires(comparer != null, null, "comparer != null");
			Contract.Ensures(Contract.Result<IObservable<ILookup<TKey, TElement>>>() != null, null, "Contract.Result<IObservable<ILookup<TKey, TElement>>>() != null");
			return null;
		}

		public static IObservable<TSource> ToObservable<TSource>(this IEnumerable<TSource> source)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}

		public static IObservable<TSource> ToObservable<TSource>(this IEnumerable<TSource> source, IScheduler scheduler)
		{
			Contract.Requires(source != null, null, "source != null");
			Contract.Requires(scheduler != null, null, "scheduler != null");
			Contract.Ensures(Contract.Result<IObservable<TSource>>() != null, null, "Contract.Result<IObservable<TSource>>() != null");
			return null;
		}
	}
}